#ifndef __FONTMANAGER_H__
#define __FONTMANAGER_H__

#include "../D3DRenderer/D3DRenderer.h"

namespace Renderer
{
	//--------------------------------------------------------------------
	//--------------------------------------------------------------------
	//--------------------------------------------------------------------

	class FontManager : public Renderable
	{
	public:
		FontManager(D3DRenderer& _rRenderer);
		virtual ~FontManager();

		virtual void Render();
		virtual const Matrix& GetWorldTransform() const;

		struct FontInfo
		{
			wstring			m_wstrFontName;
			unsigned int	m_uHeight;	
			unsigned int	m_uWeight; // FW_DONTCARE, FW_THIN, FW_EXTRALIGHT, ...., FW_BOLD, FW_EXTRABOLD, FW_HEAVY.
			bool			m_bItalic;
		};
		bool AddFont(const string& _strName, const FontInfo& _rInfo);
		void RemoveFont(const string& _strName);

		void SetColor(const D3DCOLOR& _rColor);
		void Printf(const string& _strName, const unsigned int& _uLeft, const unsigned int& _uTop, const wchar_t* _pwszFormat, ...);

	protected:
		typedef map<DataKey, ID3DXFont*> FontPtrMap;

		struct TextInfo
		{
			wstring		m_wstrText;
			RECT		m_oRect;
			D3DCOLOR	m_oColor;
		};
		typedef vector<TextInfo> TextInfoVec;
		typedef map<ID3DXFont*, TextInfoVec> TextInfoMap;

	protected:
		const static size_t c_TextBufferSize = 1024;

		wchar_t			m_wszBuffer[c_TextBufferSize];
		Matrix			m_oWorld;
		D3DRenderer&	m_rRenderer;
		FontPtrMap		m_mFonts;
		TextInfoMap		m_mTexts;
		ID3DXSprite*	m_pTextSprite;
		D3DCOLOR		m_oCurrentColor;
		int				m_sLogPixelsY;
	};
}

#endif // __FONTMANAGER_H__
